home *** CD-ROM | disk | FTP | other *** search
- // Dynamic link library implementation of a channel extractor
-
- #include "NSDLL.h"
-
- /***************************/
- /* Activation of component */
- __declspec(dllexport) BOOL performPrePost(
- DLLData *instance, // Pointer to instance data (may be NULL)
- NSFloat *input, // Pointer to the input data
- NSFloat *output, // Pointer to the output data
- int rows, // Number of rows of data
- int cols, // Number of cols of data
- BOOL preprocessor // Flag to indicate whether this is a preprocessor or postprocessor
- )
- {
- int i;
- int fromLength = getIntParameter(instance, 2, 0);
- int fromStart = getIntParameter(instance, 2, 1);
- int fromStop = getIntParameter(instance, 2, 2);
- int toStart = getIntParameter(instance, 3, 1);
-
- if (!preprocessor)
- for (i=0; i<=fromStop-fromStart; i++)
- output[i] = 0.0f;
- for (i=0; i<=fromStop-fromStart; i++)
- output[toStart+i] += input[fromStart+i];
- return TRUE;
- }
-
- /******************************************/
- /* Management of instance data (OPTIONAL) */
- __declspec(dllexport) DLLData *allocPrePost(
- DLLData *oldInstance, // Pointer to the last instance if reallocating
- int *rows, // Number of rows of output data, can be changed to reflect a diffenent number for the input data
- int *cols, // Number of cols of output data, can be changed to reflect a diffenent number for the input data
- BOOL preprocessor // Flag to indicate whether this is a preprocessor or postprocessor
- )
- {
- DLLData *instance = allocDLLInstance(oldInstance);
- int fromLength, toLength, fromStart, fromStop, toStart, returnMax;
-
- setParameterName(instance, 2, 1, "From Start", TRUE);
- setIntParameter(instance, 2, 1, 0, FALSE);
- setParameterName(instance, 2, 2, "From Stop", TRUE);
- setIntParameter(instance, 2, 2, 0, FALSE);
- setParameterName(instance, 3, 1, "To Start", TRUE);
- setIntParameter(instance, 3, 1, 0, FALSE);
- if (preprocessor) {
- setParameterName(instance, 2, 0, "From Length", TRUE);
- setIntParameter(instance, 2, 0, 1, FALSE);
- returnMax = fromLength = getIntParameter(instance, 2, 0);
- toLength = *rows * *cols;
- } else {
- setParameterName(instance, 2, 0, "To Length", TRUE);
- setIntParameter(instance, 2, 0, 1, FALSE);
- fromLength = *rows * *cols;
- returnMax = toLength = getIntParameter(instance, 2, 0);
- }
- if (fromLength < 1)
- fromLength = 1;
- fromStart = getIntParameter(instance, 2, 1);
- if (fromStart >= fromLength)
- fromStart = fromLength - 1;
- fromStop = getIntParameter(instance, 2, 2);
- if (fromStop < fromStart)
- fromStop = fromStart;
- if (fromStop >= fromLength)
- fromStop = fromLength - 1;
- toStart = getIntParameter(instance, 3, 1);
- if (toStart >= toLength)
- toStart = toLength - 1;
- if (toStart > toLength - (fromStop-fromStart+1))
- fromStop = fromStart + (toLength-toStart-1);
- setIntParameter(instance, 2, 1, fromStart, TRUE);
- setIntParameter(instance, 2, 2, fromStop, TRUE);
- setIntParameter(instance, 3, 1, toStart, TRUE);
- setIntParameter(instance, 2, 0, returnMax, TRUE);
- *rows = returnMax;
- *cols = 1;
- return instance;
- }
-
- __declspec(dllexport) void freePrePost(DLLData *instance)
- {
- freeDLLInstance(instance);
- }
-